<?php
declare(strict_types = 1);
namespace app\admin\middleware;

use think\Response;

class Auth {
    public function handle($request, \Closure $next){
        // 前置中间件
        if (empty(session(config('admin.session_admin')))
            && ((!preg_match("/login/", $request->pathinfo())) && (!preg_match("/verify/", $request->pathinfo())))
        ){
            return redirect((string) url('login/index'));
        }
        $response = $next($request);
//        if (empty(session(config('admin.session_admin'))) && !in_array($request->controller(), ['Login', 'Verify'])){
//            return redirect((string) url('login/index'));
//        }
        return $response;
        // 后置中间件
    }

    public function end(Response $response){

    }
}